Package org.jclouds.hpcloud.objectstorage.domain

Examples of org.jclouds.hpcloud.objectstorage.domain.CDNContainer


      @Override
      public URI load(String container) {
         Optional<CDNContainerApi> cdnExtension = client.getCDNExtension();
         checkArgument(cdnExtension.isPresent(), "CDN is required, but the extension is not available!");
         try {
            CDNContainer md = cdnExtension.get().get(container);
            return md != null ? md.getCDNUri() : null;
         } catch (HttpResponseException e) {
            // TODO: this is due to beta status
            logger.trace("couldn't get cdn metadata for %s: %s", container, e.getMessage());
            return null;
         } catch (NoSuchElementException e) {
View Full Code Here


            getApi().getCDNExtension().get().disable(containerNameWithCDN);
            getApi().getCDNExtension().get().disable(containerNameWithoutCDN);
         } catch (Exception e) {
            e.printStackTrace();
         }
         CDNContainer cdnMetadata = null;

         // Enable CDN with PUT for one container
         final URI cdnUri = getApi().getCDNExtension().get().enable(containerNameWithCDN);
         assertNotNull(cdnUri);

         // Confirm CDN is enabled via HEAD request and has default TTL
         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);

         assertTrue(cdnMetadata.isCDNEnabled());

         assertEquals(cdnMetadata.getCDNUri(), cdnUri);

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithoutCDN);
         assert cdnMetadata == null || !cdnMetadata.isCDNEnabled() : containerNameWithoutCDN
                  + " should not have metadata";

         assert getApi().getCDNExtension().get().get("DoesNotExist") == null;

         // List CDN metadata for containers, and ensure all CDN info is
         // available for enabled
         // container
         FluentIterable<CDNContainer> cdnMetadataList = getApi().getCDNExtension().get().list();
         assertTrue(cdnMetadataList.size() >= 1);

         final long initialTTL = cdnMetadata.getTTL();
         assertTrue(cdnMetadataList.contains(CDNContainer.builder().name(containerNameWithCDN)
               .CDNEnabled(true).ttl(initialTTL).CDNUri(cdnUri).build()));

         /*
          * Test listing with options FIXFIX cdnMetadataList =
          * getApi().list(ListCDNContainerOptions.Builder.enabledOnly());
          * assertTrue(Iterables.all(cdnMetadataList, new Predicate<CDNContainer>() { public
          * boolean apply(CDNContainer cdnMetadata) { return cdnMetadata.isCDNEnabled(); }
          * }));
          */

         cdnMetadataList = getApi().getCDNExtension().get().list(
                  ListCDNContainerOptions.Builder.afterMarker(
                           containerNameWithCDN.substring(0, containerNameWithCDN.length() - 1)).maxResults(1));
         assertEquals(cdnMetadataList.size(), 1);

         // Enable CDN with PUT for the same container, this time with a custom
         // TTL
         long ttl = 4000;
         getApi().getCDNExtension().get().enable(containerNameWithCDN, ttl);

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);

         assertTrue(cdnMetadata.isCDNEnabled());
  
         assertEquals(cdnMetadata.getTTL(), ttl);

         // Check POST by updating TTL settings
         ttl = minimumTTL;
         getApi().getCDNExtension().get().update(containerNameWithCDN, minimumTTL);

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);
         assertTrue(cdnMetadata.isCDNEnabled());

         assertEquals(cdnMetadata.getTTL(), minimumTTL);

         // Confirm that minimum allowed value for TTL is 3600, lower values are
         // ignored.
         getApi().getCDNExtension().get().update(containerNameWithCDN, 3599L);
         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);
         assertEquals(cdnMetadata.getTTL(), 3599L);

         // Disable CDN with POST
         assertTrue(getApi().getCDNExtension().get().disable(containerNameWithCDN));

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);
         assertEquals(cdnMetadata.isCDNEnabled(), false);
      } catch (Exception e) {
         e.printStackTrace();
      } finally {
         recycleContainer(containerNameWithCDN);
         recycleContainer(containerNameWithoutCDN);
View Full Code Here

            getApi().getCDNExtension().get().disable(containerNameWithCDN);
            getApi().getCDNExtension().get().disable(containerNameWithoutCDN);
         } catch (Exception e) {
            e.printStackTrace();
         }
         CDNContainer cdnMetadata = null;

         // Enable CDN with PUT for one container
         final URI cdnUri = getApi().getCDNExtension().get().enable(containerNameWithCDN);
         assertNotNull(cdnUri);

         // Confirm CDN is enabled via HEAD request and has default TTL
         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);

         assertTrue(cdnMetadata.isCDNEnabled());

         assertEquals(cdnMetadata.getCDNUri(), cdnUri);

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithoutCDN);
         assert cdnMetadata == null || !cdnMetadata.isCDNEnabled() : containerNameWithoutCDN
                  + " should not have metadata";

         assert getApi().getCDNExtension().get().get("DoesNotExist") == null;

         // List CDN metadata for containers, and ensure all CDN info is
         // available for enabled
         // container
         FluentIterable<CDNContainer> cdnMetadataList = getApi().getCDNExtension().get().list();
         assertTrue(cdnMetadataList.size() >= 1);

         final long initialTTL = cdnMetadata.getTTL();
         assertTrue(cdnMetadataList.contains(CDNContainer.builder().name(containerNameWithCDN)
               .CDNEnabled(true).ttl(initialTTL).CDNUri(cdnUri).build()));

         /*
          * Test listing with options FIXFIX cdnMetadataList =
          * getApi().list(ListCDNContainerOptions.Builder.enabledOnly());
          * assertTrue(Iterables.all(cdnMetadataList, new Predicate<CDNContainer>() { public
          * boolean apply(CDNContainer cdnMetadata) { return cdnMetadata.isCDNEnabled(); }
          * }));
          */

         cdnMetadataList = getApi().getCDNExtension().get().list(
                  ListCDNContainerOptions.Builder.afterMarker(
                           containerNameWithCDN.substring(0, containerNameWithCDN.length() - 1)).maxResults(1));
         assertEquals(cdnMetadataList.size(), 1);

         // Enable CDN with PUT for the same container, this time with a custom
         // TTL
         long ttl = 4000;
         getApi().getCDNExtension().get().enable(containerNameWithCDN, ttl);

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);

         assertTrue(cdnMetadata.isCDNEnabled());
  
         assertEquals(cdnMetadata.getTTL(), ttl);

         // Check POST by updating TTL settings
         ttl = minimumTTL;
         getApi().getCDNExtension().get().update(containerNameWithCDN, minimumTTL);

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);
         assertTrue(cdnMetadata.isCDNEnabled());

         assertEquals(cdnMetadata.getTTL(), minimumTTL);

         // Confirm that minimum allowed value for TTL is 3600, lower values are
         // ignored.
         getApi().getCDNExtension().get().update(containerNameWithCDN, 3599L);
         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);
         assertEquals(cdnMetadata.getTTL(), 3599L);

         // Disable CDN with POST
         assertTrue(getApi().getCDNExtension().get().disable(containerNameWithCDN));

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);
         assertEquals(cdnMetadata.isCDNEnabled(), false);
      } catch (Exception e) {
         e.printStackTrace();
      } finally {
         recycleContainer(containerNameWithCDN);
         recycleContainer(containerNameWithoutCDN);
View Full Code Here

      @Override
      public URI load(String container) {
         Optional<CDNContainerApi> cdnExtension = client.getCDNExtension();
         checkArgument(cdnExtension.isPresent(), "CDN is required, but the extension is not available!");
         try {
            CDNContainer md = cdnExtension.get().get(container);
            return md != null ? md.getCDNUri() : null;
         } catch (HttpResponseException e) {
            // TODO: this is due to beta status
            logger.trace("couldn't get cdn metadata for %s: %s", container, e.getMessage());
            return null;
         } catch (NoSuchElementException e) {
View Full Code Here

            getApi().getCDNExtension().get().disable(containerNameWithCDN);
            getApi().getCDNExtension().get().disable(containerNameWithoutCDN);
         } catch (Exception e) {
            e.printStackTrace();
         }
         CDNContainer cdnMetadata = null;

         // Enable CDN with PUT for one container
         final URI cdnUri = getApi().getCDNExtension().get().enable(containerNameWithCDN);
         assertNotNull(cdnUri);

         // Confirm CDN is enabled via HEAD request and has default TTL
         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);

         assertTrue(cdnMetadata.isCDNEnabled());

         assertEquals(cdnMetadata.getCDNUri(), cdnUri);

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithoutCDN);
         assert cdnMetadata == null || !cdnMetadata.isCDNEnabled() : containerNameWithoutCDN
                  + " should not have metadata";

         assert getApi().getCDNExtension().get().get("DoesNotExist") == null;

         // List CDN metadata for containers, and ensure all CDN info is
         // available for enabled
         // container
         FluentIterable<CDNContainer> cdnMetadataList = getApi().getCDNExtension().get().list();
         assertTrue(cdnMetadataList.size() >= 1);

         final long initialTTL = cdnMetadata.getTTL();
         assertTrue(cdnMetadataList.contains(CDNContainer.builder().name(containerNameWithCDN)
               .CDNEnabled(true).ttl(initialTTL).CDNUri(cdnUri).build()));

         /*
          * Test listing with options FIXFIX cdnMetadataList =
          * getApi().list(ListCDNContainerOptions.Builder.enabledOnly());
          * assertTrue(Iterables.all(cdnMetadataList, new Predicate<CDNContainer>() { public
          * boolean apply(CDNContainer cdnMetadata) { return cdnMetadata.isCDNEnabled(); }
          * }));
          */

         cdnMetadataList = getApi().getCDNExtension().get().list(
                  ListCDNContainerOptions.Builder.afterMarker(
                           containerNameWithCDN.substring(0, containerNameWithCDN.length() - 1)).maxResults(1));
         assertEquals(cdnMetadataList.size(), 1);

         // Enable CDN with PUT for the same container, this time with a custom
         // TTL
         long ttl = 4000;
         getApi().getCDNExtension().get().enable(containerNameWithCDN, ttl);

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);

         assertTrue(cdnMetadata.isCDNEnabled());
  
         assertEquals(cdnMetadata.getTTL(), ttl);

         // Check POST by updating TTL settings
         ttl = minimumTTL;
         getApi().getCDNExtension().get().update(containerNameWithCDN, minimumTTL);

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);
         assertTrue(cdnMetadata.isCDNEnabled());

         assertEquals(cdnMetadata.getTTL(), minimumTTL);

         // Confirm that minimum allowed value for TTL is 3600, lower values are
         // ignored.
         getApi().getCDNExtension().get().update(containerNameWithCDN, 3599L);
         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);
         assertEquals(cdnMetadata.getTTL(), 3599L);

         // Disable CDN with POST
         assertTrue(getApi().getCDNExtension().get().disable(containerNameWithCDN));

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);
         assertEquals(cdnMetadata.isCDNEnabled(), false);
      } catch (Exception e) {
         e.printStackTrace();
      } finally {
         recycleContainer(containerNameWithCDN);
         recycleContainer(containerNameWithoutCDN);
View Full Code Here

      @Override
      public URI load(String container) {
         Optional<CDNContainerApi> cdnExtension = client.getCDNExtension();
         checkArgument(cdnExtension.isPresent(), "CDN is required, but the extension is not available!");
         try {
            CDNContainer md = cdnExtension.get().get(container);
            return md != null ? md.getCDNUri() : null;
         } catch (HttpResponseException e) {
            // TODO: this is due to beta status
            logger.trace("couldn't get cdn metadata for %s: %s", container, e.getMessage());
            return null;
         } catch (NoSuchElementException e) {
View Full Code Here

      @Override
      public URI load(String container) {
         Optional<CDNContainerApi> cdnExtension = client.getCDNExtension();
         checkArgument(cdnExtension.isPresent(), "CDN is required, but the extension is not available!");
         try {
            CDNContainer md = cdnExtension.get().get(container);
            return md != null ? md.getCDNUri() : null;
         } catch (HttpResponseException e) {
            // TODO: this is due to beta status
            logger.trace("couldn't get cdn metadata for %s: %s", container, e.getMessage());
            return null;
         } catch (NoSuchElementException e) {
View Full Code Here

            getApi().getCDNExtension().get().disable(containerNameWithCDN);
            getApi().getCDNExtension().get().disable(containerNameWithoutCDN);
         } catch (Exception e) {
            e.printStackTrace();
         }
         CDNContainer cdnMetadata = null;

         // Enable CDN with PUT for one container
         final URI cdnUri = getApi().getCDNExtension().get().enable(containerNameWithCDN);
         assertNotNull(cdnUri);

         // Confirm CDN is enabled via HEAD request and has default TTL
         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);

         assertTrue(cdnMetadata.isCDNEnabled());

         assertEquals(cdnMetadata.getCDNUri(), cdnUri);

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithoutCDN);
         assert cdnMetadata == null || !cdnMetadata.isCDNEnabled() : containerNameWithoutCDN
                  + " should not have metadata";

         assert getApi().getCDNExtension().get().get("DoesNotExist") == null;

         // List CDN metadata for containers, and ensure all CDN info is
         // available for enabled
         // container
         FluentIterable<CDNContainer> cdnMetadataList = getApi().getCDNExtension().get().list();
         assertTrue(cdnMetadataList.size() >= 1);

         final long initialTTL = cdnMetadata.getTTL();
         assertTrue(cdnMetadataList.contains(CDNContainer.builder().name(containerNameWithCDN)
               .CDNEnabled(true).ttl(initialTTL).CDNUri(cdnUri).build()));

         /*
          * Test listing with options FIXFIX cdnMetadataList =
          * getApi().list(ListCDNContainerOptions.Builder.enabledOnly());
          * assertTrue(Iterables.all(cdnMetadataList, new Predicate<CDNContainer>() { public
          * boolean apply(CDNContainer cdnMetadata) { return cdnMetadata.isCDNEnabled(); }
          * }));
          */

         cdnMetadataList = getApi().getCDNExtension().get().list(
                  ListCDNContainerOptions.Builder.afterMarker(
                           containerNameWithCDN.substring(0, containerNameWithCDN.length() - 1)).maxResults(1));
         assertEquals(cdnMetadataList.size(), 1);

         // Enable CDN with PUT for the same container, this time with a custom
         // TTL
         long ttl = 4000;
         getApi().getCDNExtension().get().enable(containerNameWithCDN, ttl);

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);

         assertTrue(cdnMetadata.isCDNEnabled());
  
         assertEquals(cdnMetadata.getTTL(), ttl);

         // Check POST by updating TTL settings
         ttl = minimumTTL;
         getApi().getCDNExtension().get().update(containerNameWithCDN, minimumTTL);

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);
         assertTrue(cdnMetadata.isCDNEnabled());

         assertEquals(cdnMetadata.getTTL(), minimumTTL);

         // Confirm that minimum allowed value for TTL is 3600, lower values are
         // ignored.
         getApi().getCDNExtension().get().update(containerNameWithCDN, 3599L);
         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);
         assertEquals(cdnMetadata.getTTL(), 3599L);

         // Disable CDN with POST
         assertTrue(getApi().getCDNExtension().get().disable(containerNameWithCDN));

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);
         assertEquals(cdnMetadata.isCDNEnabled(), false);
      } catch (Exception e) {
         e.printStackTrace();
      } finally {
         recycleContainer(containerNameWithCDN);
         recycleContainer(containerNameWithoutCDN);
View Full Code Here

            getApi().getCDNExtension().get().disable(containerNameWithCDN);
            getApi().getCDNExtension().get().disable(containerNameWithoutCDN);
         } catch (Exception e) {
            e.printStackTrace();
         }
         CDNContainer cdnMetadata = null;

         // Enable CDN with PUT for one container
         final URI cdnUri = getApi().getCDNExtension().get().enable(containerNameWithCDN);
         assertNotNull(cdnUri);

         // Confirm CDN is enabled via HEAD request and has default TTL
         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);

         assertTrue(cdnMetadata.isCDNEnabled());

         assertEquals(cdnMetadata.getCDNUri(), cdnUri);

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithoutCDN);
         assert cdnMetadata == null || !cdnMetadata.isCDNEnabled() : containerNameWithoutCDN
                  + " should not have metadata";

         assert getApi().getCDNExtension().get().get("DoesNotExist") == null;

         // List CDN metadata for containers, and ensure all CDN info is
         // available for enabled
         // container
         FluentIterable<CDNContainer> cdnMetadataList = getApi().getCDNExtension().get().list();
         assertTrue(cdnMetadataList.size() >= 1);

         final long initialTTL = cdnMetadata.getTTL();
         assertTrue(cdnMetadataList.contains(CDNContainer.builder().name(containerNameWithCDN)
               .CDNEnabled(true).ttl(initialTTL).CDNUri(cdnUri).build()));

         /*
          * Test listing with options FIXFIX cdnMetadataList =
          * getApi().list(ListCDNContainerOptions.Builder.enabledOnly());
          * assertTrue(Iterables.all(cdnMetadataList, new Predicate<CDNContainer>() { public
          * boolean apply(CDNContainer cdnMetadata) { return cdnMetadata.isCDNEnabled(); }
          * }));
          */

         cdnMetadataList = getApi().getCDNExtension().get().list(
                  ListCDNContainerOptions.Builder.afterMarker(
                           containerNameWithCDN.substring(0, containerNameWithCDN.length() - 1)).maxResults(1));
         assertEquals(cdnMetadataList.size(), 1);

         // Enable CDN with PUT for the same container, this time with a custom
         // TTL
         long ttl = 4000;
         getApi().getCDNExtension().get().enable(containerNameWithCDN, ttl);

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);

         assertTrue(cdnMetadata.isCDNEnabled());
  
         assertEquals(cdnMetadata.getTTL(), ttl);

         // Check POST by updating TTL settings
         ttl = minimumTTL;
         getApi().getCDNExtension().get().update(containerNameWithCDN, minimumTTL);

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);
         assertTrue(cdnMetadata.isCDNEnabled());

         assertEquals(cdnMetadata.getTTL(), minimumTTL);

         // Confirm that minimum allowed value for TTL is 3600, lower values are
         // ignored.
         getApi().getCDNExtension().get().update(containerNameWithCDN, 3599L);
         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);
         assertEquals(cdnMetadata.getTTL(), 3599L);

         // Disable CDN with POST
         assertTrue(getApi().getCDNExtension().get().disable(containerNameWithCDN));

         cdnMetadata = getApi().getCDNExtension().get().get(containerNameWithCDN);
         assertEquals(cdnMetadata.isCDNEnabled(), false);
      } catch (Exception e) {
         e.printStackTrace();
      } finally {
         recycleContainer(containerNameWithCDN);
         recycleContainer(containerNameWithoutCDN);
View Full Code Here

      @Override
      public URI load(String container) {
         Optional<CDNContainerApi> cdnExtension = client.getCDNExtension();
         checkArgument(cdnExtension.isPresent(), "CDN is required, but the extension is not available!");
         try {
            CDNContainer md = cdnExtension.get().get(container);
            return md != null ? md.getCDNUri() : null;
         } catch (HttpResponseException e) {
            // TODO: this is due to beta status
            logger.trace("couldn't get cdn metadata for %s: %s", container, e.getMessage());
            return null;
         } catch (NoSuchElementException e) {
View Full Code Here

TOP

Related Classes of org.jclouds.hpcloud.objectstorage.domain.CDNContainer

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.