当前位置: 首页>>代码示例>>Java>>正文


Java RetryParams类代码示例

本文整理汇总了Java中com.google.appengine.tools.cloudstorage.RetryParams的典型用法代码示例。如果您正苦于以下问题:Java RetryParams类的具体用法?Java RetryParams怎么用?Java RetryParams使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RetryParams类属于com.google.appengine.tools.cloudstorage包,在下文中一共展示了RetryParams类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ObjectifyStorageIo

import com.google.appengine.tools.cloudstorage.RetryParams; //导入依赖的package包/类
ObjectifyStorageIo() {
  RetryParams retryParams = new RetryParams.Builder().initialRetryDelayMillis(100)
    .retryMaxAttempts(10)
    .totalRetryPeriodMillis(10000).build();
  if (DEBUG) {
    LOG.log(Level.INFO, "RetryParams: getInitialRetryDelayMillis() = " + retryParams.getInitialRetryDelayMillis());
    LOG.log(Level.INFO, "RetryParams: getRequestTimeoutMillis() = " + retryParams.getRequestTimeoutMillis());
    LOG.log(Level.INFO, "RetryParams: getRetryDelayBackoffFactor() = " + retryParams.getRetryDelayBackoffFactor());
    LOG.log(Level.INFO, "RetryParams: getRetryMaxAttempts() = " + retryParams.getRetryMaxAttempts());
    LOG.log(Level.INFO, "RetryParams: getRetryMinAttempts() = " + retryParams.getRetryMinAttempts());
    LOG.log(Level.INFO, "RetryParams: getTotalRetryPeriodMillis() = " + retryParams.getTotalRetryPeriodMillis());
  }
  gcsService = GcsServiceFactory.createGcsService(retryParams);
  memcache.setErrorHandler(ErrorHandlers.getConsistentLogAndContinue(Level.INFO));
  initMotd();
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:17,代码来源:ObjectifyStorageIo.java

示例2: reduce

import com.google.appengine.tools.cloudstorage.RetryParams; //导入依赖的package包/类
@Override
public void reduce(String tld, ReducerInput<String> stanzas) {
  String stanzaCounter = tld + " stanzas";
  GcsFilename filename =
      new GcsFilename(bucket, String.format(FILENAME_FORMAT, tld, exportTime));
  GcsUtils cloudStorage =
      new GcsUtils(createGcsService(RetryParams.getDefaultInstance()), gcsBufferSize);
  try (OutputStream gcsOutput = cloudStorage.openOutputStream(filename);
      Writer osWriter = new OutputStreamWriter(gcsOutput, UTF_8);
      PrintWriter writer = new PrintWriter(osWriter)) {
    writer.printf(HEADER_FORMAT, tld);
    for (Iterator<String> stanzaIter = filter(stanzas, Objects::nonNull);
        stanzaIter.hasNext(); ) {
      writer.println(stanzaIter.next());
      getContext().incrementCounter(stanzaCounter);
    }
    writer.flush();
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:google,项目名称:nomulus,代码行数:22,代码来源:GenerateZoneFilesAction.java

示例3: reduce

import com.google.appengine.tools.cloudstorage.RetryParams; //导入依赖的package包/类
@Override
public void reduce(String tld, ReducerInput<String> fqdns) {
  GcsFilename filename = new GcsFilename(gcsBucket, tld + ".txt");
  GcsUtils cloudStorage =
      new GcsUtils(createGcsService(RetryParams.getDefaultInstance()), gcsBufferSize);
  try (OutputStream gcsOutput = cloudStorage.openOutputStream(filename);
      Writer osWriter = new OutputStreamWriter(gcsOutput, UTF_8);
      PrintWriter writer = new PrintWriter(osWriter)) {
    long count;
    for (count = 0; fqdns.hasNext(); count++) {
      writer.println(fqdns.next());
    }
    writer.flush();
    getContext().incrementCounter("tld domain lists written out");
    logger.infofmt("Wrote out %d domains for tld %s.", count, tld);
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:google,项目名称:nomulus,代码行数:20,代码来源:ExportDomainListsAction.java

示例4: create

import com.google.appengine.tools.cloudstorage.RetryParams; //导入依赖的package包/类
@Override
public void create(HttpServletRequest request, HttpServletResponse resp)
        throws IOException {
    Objectify ofy = DefaultServlet.getObjectify();
    final GcsService gcsService =
            GcsServiceFactory.createGcsService(RetryParams
                    .getDefaultInstance());

    GcsFilename fileName = new GcsFilename("npackd", tag + ".xml");
    GcsFileMetadata md = gcsService.getMetadata(fileName);

    if (md == null) {
        ExportRepsAction.export(gcsService, ofy, tag, false);
        md = gcsService.getMetadata(fileName);
    }

    NWUtils.serveFileFromGCS(gcsService, md, request, resp,
            "application/xml");
}
 
开发者ID:tim-lebedkov,项目名称:npackd-gae-web,代码行数:20,代码来源:RepXMLPage.java

示例5: create

import com.google.appengine.tools.cloudstorage.RetryParams; //导入依赖的package包/类
@Override
public void create(HttpServletRequest request, HttpServletResponse resp)
        throws IOException {
    Objectify ofy = DefaultServlet.getObjectify();
    final GcsService gcsService =
            GcsServiceFactory.createGcsService(RetryParams
                    .getDefaultInstance());

    GcsFilename fileName = new GcsFilename("npackd", tag + ".zip");
    GcsFileMetadata md = gcsService.getMetadata(fileName);

    if (md == null) {
        ExportRepsAction.export(gcsService, ofy, tag, false);
        md = gcsService.getMetadata(fileName);
    }

    NWUtils.serveFileFromGCS(gcsService, md, request, resp,
            "application/zip");
}
 
开发者ID:tim-lebedkov,项目名称:npackd-gae-web,代码行数:20,代码来源:RepZIPPage.java

示例6: perform

import com.google.appengine.tools.cloudstorage.RetryParams; //导入依赖的package包/类
@Override
public Page perform(HttpServletRequest req, HttpServletResponse resp)
        throws IOException {
    final GcsService gcsService =
            GcsServiceFactory.createGcsService(RetryParams
                    .getDefaultInstance());

    Objectify ofy = DefaultServlet.getObjectify();
    List<Repository> rs = Repository.findAll(ofy);
    for (Repository r : rs) {
        export(gcsService, ofy, r.name, true);
    }
    resp.setStatus(200);
    return null;
}
 
开发者ID:tim-lebedkov,项目名称:npackd-gae-web,代码行数:16,代码来源:ExportRepsAction.java

示例7: toTaskOptions

import com.google.appengine.tools.cloudstorage.RetryParams; //导入依赖的package包/类
private TaskOptions toTaskOptions(Task task) {
  final QueueSettings queueSettings = task.getQueueSettings();

  TaskOptions taskOptions = TaskOptions.Builder.withUrl(TaskHandler.handleTaskUrl());
  if (queueSettings.getOnBackend() != null) {
    taskOptions.header("Host", BackendServiceFactory.getBackendService().getBackendAddress(
        queueSettings.getOnBackend()));
  } else {

    String versionHostname = RetryHelper.runWithRetries(new Callable<String>() {
      @Override
      public String call() {
        ModulesService service = ModulesServiceFactory.getModulesService();
        String module = queueSettings.getOnModule();
        String version = queueSettings.getModuleVersion();
        if (module == null) {
          module = service.getCurrentModule();
          version = service.getCurrentVersion();
        }
        return service.getVersionHostname(module, version);
      }
    }, RetryParams.getDefaultInstance(), MODULES_EXCEPTION_HANDLER);
    taskOptions.header("Host", versionHostname);
  }

  Long delayInSeconds = queueSettings.getDelayInSeconds();
  if (null != delayInSeconds) {
    taskOptions.countdownMillis(delayInSeconds * 1000L);
    queueSettings.setDelayInSeconds(null);
  }
  addProperties(taskOptions, task.toProperties());
  String taskName = task.getName();
  if (null != taskName) {
    taskOptions.taskName(taskName);
  }
  return taskOptions;
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-pipelines,代码行数:38,代码来源:AppEngineTaskQueue.java

示例8: writeImageDataToGcs

import com.google.appengine.tools.cloudstorage.RetryParams; //导入依赖的package包/类
/**
 * Writes a byte array {@code imageData} as image to the Google Cloud Storage,
 * with the {@code googleId} as the identifier name for the image.
 *
 * @return the {@link BlobKey} used as the image's identifier in Google Cloud Storage
 */
public static String writeImageDataToGcs(String googleId, byte[] imageData) throws IOException {
    GcsFilename gcsFilename = new GcsFilename(Config.GCS_BUCKETNAME, googleId);
    try (GcsOutputChannel outputChannel =
            GcsServiceFactory.createGcsService(RetryParams.getDefaultInstance())
            .createOrReplace(gcsFilename, new GcsFileOptions.Builder().mimeType("image/png").build())) {

        outputChannel.write(ByteBuffer.wrap(imageData));
    }

    return BlobstoreServiceFactory.getBlobstoreService()
            .createGsBlobKey("/gs/" + Config.GCS_BUCKETNAME + "/" + googleId).getKeyString();
}
 
开发者ID:TEAMMATES,项目名称:teammates,代码行数:19,代码来源:GoogleCloudStorageHelper.java

示例9: export

import com.google.appengine.tools.cloudstorage.RetryParams; //导入依赖的package包/类
/**
 * Exports a repository.
 *
 * @param ob Objectify instance
 * @param recreate true = recreate the repository if it already exists
 * @return the repository with blobFile != null
 * @throws java.io.IOException any error
 */
public static Repository export(Objectify ob, boolean recreate)
        throws IOException {
    final String tag = "vim-org";

    URLFetchService s = URLFetchServiceFactory.getURLFetchService();
    HTTPRequest request =
            new HTTPRequest(
                    new URL(
                            "https://bitbucket.org/vimcommunity/vim-pi/raw/51a23481851685dda95cae07e97185870cf67723/db/vimorgsources.json"));
    request.getFetchOptions().setDeadline(60.0);
    HTTPResponse response = s.fetch(request);
    byte[] content = response.getContent();
    byte[] content2 = Arrays.copyOf(content, content.length - 1);
    content2[content2.length - 2] = '}';

    ByteArrayInputStream bais = new ByteArrayInputStream(content2);
    InputStreamReader isr = new InputStreamReader(bais, "UTF-8");
    JsonReader jr = new JsonReader(isr);
    jr.setLenient(true);
    JsonElement e = new JsonParser().parse(jr);

    Repository r = ob.find(new Key<Repository>(Repository.class, tag));
    if (r == null) {
        r = new Repository();
        r.name = tag;
        NWUtils.saveRepository(ob, r);
    }

    final GcsService gcsService =
            GcsServiceFactory.createGcsService(RetryParams
                    .getDefaultInstance());

    GcsFilename fileName = new GcsFilename("npackd", tag + ".xml");

    boolean exists = gcsService.getMetadata(fileName) != null;

    if (r.blobFile == null || recreate || !exists) {
        GcsOutputChannel outputChannel =
                gcsService.createOrReplace(fileName,
                        GcsFileOptions.getDefaultInstance());

        Document d = toXML(e);

        OutputStream oout = Channels.newOutputStream(outputChannel);
        NWUtils.serializeXML(d, oout);
        NWUtils.serializeXML(d, System.out);
        oout.close();

        r.blobFile =
                "/gs/" + fileName.getBucketName() + "/" +
                fileName.getObjectName();

        NWUtils.saveRepository(ob, r);
    }

    return r;
}
 
开发者ID:tim-lebedkov,项目名称:npackd-gae-web,代码行数:66,代码来源:ExportDefaultVimRepAction.java


注:本文中的com.google.appengine.tools.cloudstorage.RetryParams类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。