Package com.google.walkaround.util.server

Examples of com.google.walkaround.util.server.RetryHelper


  private static class Handler {
    @Inject @ConvStore SlobFacilities facilities;
    @Inject WaveIndexer indexer;

    void process(final Key key) throws PermanentFailure {
      new RetryHelper().run(new RetryHelper.VoidBody() {
          @Override public void run() throws PermanentFailure, RetryableFailure {
            SlobId objectId = facilities.parseRootEntityKey(key);
            // Update search index
            try {
              indexer.indexConversation(objectId);
View Full Code Here


      history = serializeChanges(
          InitialOps.conversationWaveletOps(participantId, System.currentTimeMillis(), random64));
    }
    SlobId newId;
    try {
      newId = new RetryHelper().run(
          new RetryHelper.Body<SlobId>() {
            @Override public SlobId run() throws RetryableFailure, PermanentFailure {
              SlobId convId = getRandomObjectId();
              CheckedTransaction tx = datastore.beginTransaction();
              try {
View Full Code Here

  }

  @Override
  public Permissions getPermissions(final SlobId slobId) throws IOException {
    try {
      return new RetryHelper().run(
          new RetryHelper.Body<Permissions>() {
            @Override public Permissions run() throws RetryableFailure, PermanentFailure {
              CheckedTransaction tx = datastore.beginTransaction();
              try {
                ConvMetadata metadata = convMetadataStore.get(tx, slobId);
View Full Code Here

  }

  private SlobId newUdwWithGeneratedId(final String metadata,
      final List<ChangeData<String>> initialHistory) throws IOException {
    try {
      return new RetryHelper().run(
          new RetryHelper.Body<SlobId>() {
            @Override public SlobId run() throws RetryableFailure, PermanentFailure {
              SlobId udwId = getRandomObjectId();
              CheckedTransaction tx = datastore.beginTransaction();
              try {
View Full Code Here

    final String url = instance.getFullAttachmentUrl(info.getPath());
    final Long expectedBytes = info.hasSizeBytes() ? info.getSizeBytes() : null;
    final String mimeType = info.hasMimeType() ? info.getMimeType() : null;
    final String filename = info.hasFilename() ? info.getFilename() : DEFAULT_FILE_NAME;
    try {
      return new RetryHelper().run(
          new RetryHelper.Body<AttachmentId>() {
            @Override public AttachmentId run() throws RetryableFailure, PermanentFailure {
              log.info("Fetching attachment " + url);
              try {
                // We could fetch several attachments asynchronously in parallel to save instance
                // hours, but let's hope that the connection between App Engine and Google Wave
                // is fast enough to make that irrelevant.
                HTTPResponse response = urlfetch.fetch(
                    new HTTPRequest(new URL(url), HTTPMethod.GET));
                if (response.getResponseCode() != 200) {
                  throw new RetryableFailure("Unexpected response code: "
                      + response.getResponseCode());
                }
                byte[] bytes = response.getContent();
                if (expectedBytes != null) {
                  Assert.check(expectedBytes == bytes.length, "Expected %s bytes, got %s: %s",
                      expectedBytes, bytes.length, prettyBytes(bytes));
                }
                final AppEngineFile file = dump(mimeType, filename, ByteBuffer.wrap(bytes));
                log.info("Wrote file " + file);
                BlobKey blobKey =
                    // NOTE(ohler): When running locally with unapplied jobs
                    // enabled, getBlobKey() sometimes returns null here even
                    // though it shouldn't, according to its documentation.  So
                    // we retry.  Not sure if this is needed when deployed.
                    new RetryHelper().run(
                        new RetryHelper.Body<BlobKey>() {
                          @Override public BlobKey run() throws RetryableFailure {
                            BlobKey key = getFileService().getBlobKey(file);
                            if (key != null) {
                              return key;
View Full Code Here

  private static class Handler {
    @Inject PerUserTable perUserTable;

    void process(Context context, final Entity entity) throws PermanentFailure {
      new RetryHelper().run(new RetryHelper.VoidBody() {
          @Override public void run() throws PermanentFailure, RetryableFailure {
            perUserTable.rescheduleExistingTask(perUserTable.parseTaskEntity(entity));
          }
        });
    }
View Full Code Here

            .validateCertificate().setDeadline(20.0));
    log.info("payload=" + ops);
    req.setHeader(new HTTPHeader("Content-Type", "application/json; charset=UTF-8"));
    req.setPayload(ops.toString().getBytes(Charsets.UTF_8));
    try {
      return new RetryHelper(RetryHelper.backoffStrategy(0, 1000, 10 * 60 * 1000))
          .run(new RetryHelper.Body<JSONObject>() {
            @Override public JSONObject run() throws RetryableFailure, PermanentFailure {
              JSONObject result;
              try {
                result = parseJsonResponseBody(fetch.fetch(req, robotErrorCode401Detector));
View Full Code Here

  }

  public void putWithoutTx(final T newEntry) throws IOException {
    Preconditions.checkNotNull(newEntry, "Null newEntry");
    try {
      new RetryHelper().run(new RetryHelper.VoidBody() {
        @Override public void run() throws RetryableFailure, PermanentFailure {
          CheckedTransaction tx = datastore.beginTransaction();
          try {
            put(tx, newEntry);
            tx.commit();
View Full Code Here

  // Is this method worthwhile, given that a caller can just use get() and put()
  // and manage their own transaction?
  @Nullable public T getOrAdd(final T newEntry) throws IOException {
    Preconditions.checkNotNull(newEntry, "Null newEntry");
    try {
      return new RetryHelper().run(new RetryHelper.Body<T>() {
        @Override public T run() throws RetryableFailure, PermanentFailure {
          CheckedTransaction tx = datastore.beginTransaction();
          try {
            Entity existing = tx.get(makeKey(getId(newEntry)));
            if (existing != null) {
View Full Code Here

  // generated, but existing instances will continue to use the old one.
  // Re-deploying should fix this since it restarts all instances.
  @Singleton
  Secret provideSecret(final CheckedDatastore datastore, final Random random)
      throws PermanentFailure {
    return new RetryHelper().run(
        new RetryHelper.Body<Secret>() {
          @Override public Secret run() throws RetryableFailure, PermanentFailure {
            CheckedTransaction tx = datastore.beginTransaction();
            try {
              {
View Full Code Here

TOP

Related Classes of com.google.walkaround.util.server.RetryHelper

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.