Package org.jclouds.io

Examples of org.jclouds.io.Payload


      assertEquals(filtered.getPayload().getContentMetadata().getContentType(),
            "application/vnd.abiquo.racks+xml;version=" + AbiquoApi.API_VERSION);
   }

   public void testFilterWithAcceptAndContentTypeWithVersion() {
      Payload payload = Payloads.newByteArrayPayload(new byte[] {});
      payload.getContentMetadata().setContentType("application/vnd.abiquo.racks+xml;version=2.1-SNAPSHOT");

      Multimap<String, String> headers = LinkedHashMultimap.<String, String> create();
      headers.put(HttpHeaders.ACCEPT, "application/vnd.abiquo.racks+xml;version=2.1-SNAPSHOT");

      HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).headers(headers)
View Full Code Here


      assertEquals(filtered.getPayload().getContentMetadata().getContentType(),
            "application/vnd.abiquo.racks+xml;version=2.1-SNAPSHOT");
   }

   public void testFilterWithAcceptAndContentTypeWithoutVersion() {
      Payload payload = Payloads.newByteArrayPayload(new byte[] {});
      payload.getContentMetadata().setContentType("application/vnd.abiquo.racks+xml");

      Multimap<String, String> headers = LinkedHashMultimap.<String, String> create();
      headers.put(HttpHeaders.ACCEPT, "application/vnd.abiquo.racks+xml");

      HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).headers(headers)
View Full Code Here

      assertEquals(filtered.getPayload().getContentMetadata().getContentType(),
            "application/vnd.abiquo.racks+xml;version=" + AbiquoApi.API_VERSION);
   }

   public void testFilterWithversionInAccept() {
      Payload payload = Payloads.newByteArrayPayload(new byte[] {});
      payload.getContentMetadata().setContentType("application/vnd.abiquo.racks+xml");

      Multimap<String, String> headers = LinkedHashMultimap.<String, String> create();
      headers.put(HttpHeaders.ACCEPT, "application/vnd.abiquo.racks+xml;version=1.8.5");

      HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).headers(headers)
View Full Code Here

      assertEquals(filtered.getPayload().getContentMetadata().getContentType(),
            "application/vnd.abiquo.racks+xml;version=" + AbiquoApi.API_VERSION);
   }

   public void testFilterWithversionInContentType() {
      Payload payload = Payloads.newByteArrayPayload(new byte[] {});
      payload.getContentMetadata().setContentType("application/vnd.abiquo.racks+xml;version=1.8.5");

      Multimap<String, String> headers = LinkedHashMultimap.<String, String> create();
      headers.put(HttpHeaders.ACCEPT, "application/vnd.abiquo.racks+xml");

      HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).headers(headers)
View Full Code Here

      byte[] signature = signer.apply(on(".").join(encodedHeader, encodedClaimSet).getBytes(UTF_8));
      String encodedSignature = signature != null ?  base64Url().omitPadding().encode(signature) : "";

      // the final assertion in base 64 encoded {header}.{claimSet}.{signature} format
      String assertion = on(".").join(encodedHeader, encodedClaimSet, encodedSignature);
      Payload payload = newUrlEncodedFormPayload(ImmutableMultimap.<String, String> builder()
                           .put(GRANT_TYPE_FORM_PARAM, GRANT_TYPE_JWT_BEARER)
                           .put(ASSERTION_FORM_PARAM, assertion).build());

      return (R) request.toBuilder().payload(payload).build();
   }
View Full Code Here

         }
      };

      String ports = on(",").skipNulls().join(transform(portRanges, addQuotes));

      Payload payload = newStringPayload(
              format(toStringAndClose(FirewallApiExpectTest.class.getResourceAsStream("/firewall_insert.json")),
                      firewallName,
                      networkName,
                      on(",").skipNulls().join(transform(sourceRanges, addQuotes)),
                      on(",").skipNulls().join(transform(sourceTags, addQuotes)),
                      on(",").skipNulls().join(transform(targetTags, addQuotes)),
                      ports,
                      ports));
      payload.getContentMetadata().setContentType(MediaType.APPLICATION_JSON);
      return payload;
   }
View Full Code Here

   
    ComputeServiceContext computeServiceContext =
      ComputeServiceContextBuilder.build(clusterSpec);
    ComputeService computeService = computeServiceContext.getComputeService();

    Payload bootScript = newStringPayload(runUrls(clusterSpec.getRunUrlBase(),
      "sun/java/install",
      "apache/zookeeper/install"));
   
    TemplateBuilder templateBuilder = computeService.templateBuilder()
      .options(runScript(bootScript)
      .installPrivateKey(clusterSpec.getPrivateKey())
      .authorizePublicKey(clusterSpec.getPublicKey()));
   
    new TemplateBuilderStrategy().configureTemplateBuilder(clusterSpec,
        templateBuilder);
   
    LOG.info("Configuring template");
    Template template = templateBuilder.build();
   
    InstanceTemplate instanceTemplate = clusterSpec.getInstanceTemplate(ZOOKEEPER_ROLE);
    checkNotNull(instanceTemplate);
    int ensembleSize = instanceTemplate.getNumberOfInstances();
    Set<? extends NodeMetadata> nodeMap;
    try {
      LOG.info("Starting {} node(s)", ensembleSize);
      nodeMap = computeService.runNodesWithTag(clusterSpec.getClusterName(), ensembleSize,
      template);
      LOG.info("Nodes started: {}", nodeMap);
    } catch (RunNodesException e) {
      // TODO: can we do better here - proceed if ensemble is big enough?
      throw new IOException(e);
    }
   
    LOG.info("Authorizing firewall");
    FirewallSettings.authorizeIngress(computeServiceContext, nodeMap, clusterSpec, CLIENT_PORT);
   
    List<NodeMetadata> nodes = Lists.newArrayList(nodeMap);
   
    // Pass list of all servers in ensemble to configure script.
    // Position is significant: i-th server has id i.
    String servers = Joiner.on(' ').join(getPrivateIps(nodes));
    Payload configureScript = newStringPayload(runUrls(clusterSpec.getRunUrlBase(),
      String.format("apache/zookeeper/post-configure -c %s %s",
          clusterSpec.getProvider(),
          servers)));
    // Use private key to run script
    Credentials credentials = new Credentials(
View Full Code Here

   
    ComputeServiceContext computeServiceContext =
        ComputeServiceContextBuilder.build(clusterSpec);
    ComputeService computeService = computeServiceContext.getComputeService();

    Payload bootScript = newStringPayload(runUrls(clusterSpec.getRunUrlBase(),
        "sun/java/install",
        "apache/cassandra/install"));

    TemplateBuilder templateBuilder = computeService.templateBuilder()
        .options(
            runScript(bootScript).installPrivateKey(
                clusterSpec.getPrivateKey()).authorizePublicKey(
                clusterSpec.getPublicKey()));

    new TemplateBuilderStrategy().configureTemplateBuilder(clusterSpec,
        templateBuilder);

    LOG.info("Configuring template");
    Template template = templateBuilder.build();

    InstanceTemplate instanceTemplate = clusterSpec
        .getInstanceTemplate(CASSANDRA_ROLE);
    checkNotNull(instanceTemplate);
    int clusterSize = instanceTemplate.getNumberOfInstances();
    Set<? extends NodeMetadata> nodeMap;
    try {
      LOG.info("Starting {} node(s)", clusterSize);
      nodeMap = computeService.runNodesWithTag(clusterSpec.getClusterName(),
          clusterSize, template);
      LOG.info("Nodes started: {}", nodeMap);
    } catch (RunNodesException e) {
      // TODO: can we do better here
      throw new IOException(e);
    }
   
    LOG.info("Authorizing firewall");
    FirewallSettings.authorizeIngress(computeServiceContext, nodeMap, clusterSpec, CLIENT_PORT);

    List<NodeMetadata> nodes = Lists.newArrayList(nodeMap);
    List<NodeMetadata> seeds = getSeeds(nodes);

    // Pass list of all servers in cluster to configure script.
    String servers = Joiner.on(' ').join(getPrivateIps(seeds));
    Payload configureScript = newStringPayload(runUrls(clusterSpec.getRunUrlBase(),
        String.format("apache/cassandra/post-configure -c %s %s",
            clusterSpec.getProvider(),
            servers)));
    // Use private key to run script
    Credentials credentials = new Credentials(
View Full Code Here

    }

    public void testRanges() throws IOException {
        blobStore.createContainerInLocation(null, CONTAINER_NAME);
        String input = "abcdefgh";
        Payload payload;
        Blob blob = blobStore.blobBuilder("test").payload(new StringPayload(input)).build();
        blobStore.putBlob(CONTAINER_NAME, blob);

        GetOptions getOptionsRangeStartAt = new GetOptions();
        getOptionsRangeStartAt.startAt(1);
View Full Code Here

   public void testPutAndGet() throws IOException {
      temp = File.createTempFile("foo", "bar");
      temp.deleteOnExit();
      SshClient client = setupClient();
      client.put(temp.getAbsolutePath(), Payloads.newStringPayload("rabbit"));
      Payload input = setupClient().get(temp.getAbsolutePath());
      String contents = Strings2.toString(input);
      assertEquals(contents, "rabbit");
   }
View Full Code Here

TOP

Related Classes of org.jclouds.io.Payload

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.