Package org.apache.whirr.util

Examples of org.apache.whirr.util.BlobCache


    if (rawUrl != null && rawUrl.startsWith("file://")) {
      try {
        URI uri = new URI(rawUrl);
        File localFile = new File(uri);

        BlobCache cache = BlobCache.getInstance(event.getCompute(), event.getClusterSpec());
        cache.putIfAbsent(localFile);

        final String basePath = "/tmp/whirr/cache/files/";
        addStatement(event, cache.getAsSaveToStatement(basePath, uri));
        return "file://" + basePath + localFile.getName();

      } catch (URISyntaxException e) {
        throw new IOException(e);
      }
View Full Code Here


    if (rawUrl != null && rawUrl.startsWith("file://")) {
      try {
        URI uri = new URI(rawUrl);
        File localFile = new File(uri);

        BlobCache cache = BlobCache.getInstance(event.getCompute(), event.getClusterSpec());
        cache.putIfAbsent(localFile);

        final String basePath = "/tmp/whirr/cache/files/";
        addStatement(event, cache.getAsSaveToStatement(basePath, uri));
        return "file://" + basePath + localFile.getName();

      } catch (URISyntaxException e) {
        throw new IOException(e);
      }
View Full Code Here

      return; // this test can be executed only on amazon but the internal
      // location selection mechanism should work for any cloud provider
    }
    spec.setTemplate(TemplateBuilderSpec.parse("locationId=eu-west-1"));

    BlobCache cache = BlobCache.getInstance(ComputeCache.INSTANCE, spec);
    assertThat(cache.getLocation().getId(), is("EU"));
  }
View Full Code Here

    LOG.info("Created temporary container '{}'", container);

    try {
      spec.setBlobStoreCacheContainer(container);

      BlobCache cache = BlobCache.getInstance(ComputeCache.INSTANCE, spec);
      assertThat(cache.getContainer(), is(container));
      cache.dropAndClose();

      assertThat(context.getBlobStore().containerExists(container), is(true));

    } finally {
      LOG.info("Removing temporary container '{}'", container);
View Full Code Here

  private void testBlobCacheUpload(String payload, ClusterSpec spec)
      throws Exception {
    File tempFile = createTemporaryFile(payload);

    BlobCache cache = BlobCache.getInstance(ComputeCache.INSTANCE, spec);

    try {
      cache.putIfAbsent(tempFile);

      HttpRequest req = cache.getSignedRequest(tempFile.getName());
      assertThat(readContent(req), is(payload));

      /* render download statement for visual test inspection */
      LOG.info(cache.getAsSaveToStatement("/tmp",
          tempFile.getName()).render(OsFamily.UNIX));

    } finally {
      BlobCache.dropAndCloseAll();
    }
View Full Code Here

      throws IOException {
    if (rawUrl != null && rawUrl.startsWith("file://")) {
      try {
        URI uri = new URI(rawUrl);

        BlobCache cache = BlobCache.getInstance(event.getCompute(), event.getClusterSpec());
        cache.putIfAbsent(uri);

        String basePath = "/tmp/whirr/cache/files/";
        addStatement(event, cache.getAsSaveToStatement(basePath, uri));
        return "file://" + basePath + (new File(uri)).getName();

      } catch (URISyntaxException e) {
        throw new IOException(e);
      }
View Full Code Here

  public void testUploadFileToBlobCache() throws Exception {
    String expected = "dummy content";
    File tempFile = createTemporaryFile(expected);

    ClusterSpec spec = getTestClusterSpec();
    BlobCache cache = BlobCache.getInstance(ComputeCache.INSTANCE, spec);

    try {
      cache.putIfAbsent(tempFile);

      HttpRequest req = cache.getSignedRequest(tempFile.getName());
      assertThat(readContent(req), is(expected));

      /* render download statement for visual test inspection */
      LOG.info(cache.getAsSaveToStatement("/tmp",
          tempFile.getName()).render(OsFamily.UNIX));

    } finally {
      BlobCache.dropAndCloseAll();
    }
View Full Code Here

      return; // this test can be executed only on amazon but the internal
      // location selection mechanism should work for any cloud provider
    }
    spec.setLocationId("eu-west-1");

    BlobCache cache = BlobCache.getInstance(ComputeCache.INSTANCE, spec);
    assertThat(cache.getLocation().getId(), is("EU"));
  }
View Full Code Here

    if (rawUrl != null && rawUrl.startsWith("file://")) {
      try {
        URI uri = new URI(rawUrl);
        File localFile = new File(uri);

        BlobCache cache = BlobCache.getInstance(event.getCompute(), event.getClusterSpec());
        cache.putIfAbsent(localFile);

        final String basePath = "/tmp/whirr/cache/files/";
        addStatement(event, cache.getAsSaveToStatement(basePath, uri));
        return "file://" + basePath + localFile.getName();

      } catch (URISyntaxException e) {
        throw new IOException(e);
      }
View Full Code Here

      return; // this test can be executed only on amazon but the internal
      // location selection mechanism should work for any cloud provider
    }
    spec.setLocationId("eu-west-1");

    BlobCache cache = BlobCache.getInstance(ComputeCache.INSTANCE, spec);
    assertThat(cache.getLocation().getId(), is("EU"));
  }
View Full Code Here

TOP

Related Classes of org.apache.whirr.util.BlobCache

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.