Package org.jclouds.compute

Examples of org.jclouds.compute.ComputeServiceContext


 
  @Override
  public ZooKeeperCluster launchCluster(ClusterSpec clusterSpec) throws IOException {
    LOG.info("Launching " + clusterSpec.getClusterName() + " cluster");
   
    ComputeServiceContext computeServiceContext =
      ComputeServiceContextBuilder.build(clusterSpec);
    ComputeService computeService = computeServiceContext.getComputeService();

    Payload bootScript = newStringPayload(runUrls(clusterSpec.getRunUrlBase(),
      "sun/java/install",
      "apache/zookeeper/install"));
   
View Full Code Here


  @Override
  public Cluster launchCluster(ClusterSpec clusterSpec) throws IOException {
    LOG.info("Launching " + clusterSpec.getClusterName() + " cluster");
   
    ComputeServiceContext computeServiceContext =
        ComputeServiceContextBuilder.build(clusterSpec);
    ComputeService computeService = computeServiceContext.getComputeService();

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

  }
 
  public Map<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(final ClusterSpec spec,
      Predicate<NodeMetadata> condition, final Statement statement) throws IOException, RunScriptOnNodesException {
   
    ComputeServiceContext computeServiceContext = getCompute().apply(spec);
    ComputeService computeService = computeServiceContext.getComputeService();
    Cluster cluster = getClusterStateStore(spec).load();

    RunScriptOptions options = RunScriptOptions.Builder.runAsRoot(false).wrapInInitScript(false);
    return computeService.runScriptOnNodesMatching(Predicates.<NodeMetadata>and(condition, runningIn(cluster)), statement, options);
  }
View Full Code Here

  }
 
  @Override
  public Set<? extends NodeMetadata> getNodes(ClusterSpec clusterSpec)
      throws IOException, InterruptedException {
    ComputeServiceContext computeServiceContext = getCompute().apply(clusterSpec);
    ComputeService computeService = computeServiceContext.getComputeService();
    return computeService.listNodesDetailsMatching(Predicates.in(computeService.listNodes()));
  }
View Full Code Here

        .put("hadoop-namenode", handler)
        .put("hadoop-datanode", handler)
        .put("hadoop-tasktracker", handler).build());

    Function<ClusterSpec, ComputeServiceContext> getCompute = mock(Function.class);
    ComputeServiceContext serviceContext = mock(ComputeServiceContext.class);
    ComputeService computeService = mock(ComputeService.class);
    TemplateBuilder templateBuilder = mock(TemplateBuilder.class);
    Template template = mock(Template.class);
    TemplateOptions templateOptions = mock(TemplateOptions.class);
   
    when(getCompute.apply(clusterSpec)).thenReturn(serviceContext);
    when(serviceContext.getComputeService()).thenReturn(computeService);
    when(computeService.getContext()).thenReturn(serviceContext);
    when(serviceContext.getBackendType()).thenReturn(TypeToken.class.cast(TypeToken.of(Context.class)));
    when(computeService.templateBuilder()).thenReturn(templateBuilder);
    when(templateBuilder.from((TemplateBuilderSpec) any())).thenReturn(templateBuilder);
    when(templateBuilder.options((TemplateOptions) any())).thenReturn(templateBuilder);
    when(templateBuilder.build()).thenReturn(template);
    when(template.getOptions()).thenReturn(templateOptions);
View Full Code Here

        .put("hadoop-namenode", handler)
        .put("hadoop-datanode", handler)
        .put("hadoop-tasktracker", handler).build());

    Function<ClusterSpec, ComputeServiceContext> getCompute = mock(Function.class);
    ComputeServiceContext serviceContext = mock(ComputeServiceContext.class);
    ComputeService computeService = mock(ComputeService.class);
    TemplateBuilder templateBuilder = mock(TemplateBuilder.class);
    Template template = mock(Template.class);
    TemplateOptions templateOptions = mock(TemplateOptions.class);

    when(getCompute.apply(clusterSpec)).thenReturn(serviceContext);
    when(serviceContext.getComputeService()).thenReturn(computeService);
    when(computeService.getContext()).thenReturn(serviceContext);
    when(serviceContext.getBackendType()).thenReturn(TypeToken.class.cast(TypeToken.of(Context.class)));
    when(computeService.templateBuilder()).thenReturn(templateBuilder);
    when(templateBuilder.from((TemplateBuilderSpec) any())).thenReturn(templateBuilder);
    when(templateBuilder.options((TemplateOptions) any())).thenReturn(templateBuilder);
    when(templateBuilder.build()).thenReturn(template);
    when(template.getOptions()).thenReturn(templateOptions);
View Full Code Here

    LoadingCache<String, ClusterActionHandler> handlerMap = new HandlerMapFactory().create(ImmutableSet.of(puppetHandlerFactory),
          ImmutableSet.of(handler));

    Function<ClusterSpec, ComputeServiceContext> getCompute = mock(Function.class);
    ComputeServiceContext serviceContext = mock(ComputeServiceContext.class);
    ComputeService computeService = mock(ComputeService.class);
    TemplateBuilder templateBuilder = mock(TemplateBuilder.class);
    Template template = mock(Template.class);
    TemplateOptions templateOptions = mock(TemplateOptions.class);

    when(getCompute.apply(clusterSpec)).thenReturn(serviceContext);
    when(serviceContext.getComputeService()).thenReturn(computeService);
    when(computeService.getContext()).thenReturn(serviceContext);
    when(serviceContext.getBackendType()).thenReturn(TypeToken.class.cast(TypeToken.of(Context.class)));
    when(computeService.templateBuilder()).thenReturn(templateBuilder);
    when(templateBuilder.from((TemplateBuilderSpec) any())).thenReturn(templateBuilder);
    when(templateBuilder.options((TemplateOptions) any())).thenReturn(templateBuilder);
    when(templateBuilder.build()).thenReturn(template);
    when(template.getOptions()).thenReturn(templateOptions);
View Full Code Here

    LoadingCache<String, ClusterActionHandler> handlerMap = new HandlerMapFactory().create(
      ImmutableSet.of(puppetHandlerFactory), ImmutableSet.of(handler));

    Function<ClusterSpec, ComputeServiceContext> getCompute = mock(Function.class);
    ComputeServiceContext serviceContext = mock(ComputeServiceContext.class);
    ComputeService computeService = mock(ComputeService.class);
    TemplateBuilder templateBuilder = mock(TemplateBuilder.class);
    Template template = mock(Template.class);


    when(getCompute.apply(clusterSpec)).thenReturn(serviceContext);
    when(serviceContext.getComputeService()).thenReturn(computeService);
    when(computeService.templateBuilder()).thenReturn(templateBuilder);
    when(templateBuilder.from((TemplateBuilderSpec) any())).thenReturn(templateBuilder);
    when(templateBuilder.options((TemplateOptions) any())).thenReturn(templateBuilder);
    when(templateBuilder.build()).thenReturn(template);
   
View Full Code Here

      }
   }

   @Test(enabled = true) //, dependsOnMethods = "testCompareSizes")
   public void testAutoIpAllocation() throws Exception {
      ComputeServiceContext context = null;
      String group = this.group + "aip";
      try {
         Properties overrides = setupProperties();
         overrides.setProperty(EC2Constants.PROPERTY_EC2_AUTO_ALLOCATE_ELASTIC_IPS, "true");

         context = createView(overrides, setupModules());

         TemplateOptions options = client.templateOptions();

         options.blockOnPort(22, 300);
         options.inboundPorts(22);

         // create a node
         Set<? extends NodeMetadata> nodes =
               context.getComputeService().createNodesInGroup(group, 1, options);
         assertEquals(nodes.size(), 1, "One node should have been created");

         // Get public IPs (We should get 1)
         NodeMetadata node = Iterables.get(nodes, 0);
         String region = node.getLocation().getParent().getId();
         Set<String> publicIps = node.getPublicAddresses();
         assertFalse(Iterables.isEmpty(publicIps), String.format("no public addresses attached to node %s", node));
         assertEquals(Iterables.size(publicIps), 1);

         // Check that the address is public and port 22 is accessible
         String ip = Iterables.getOnlyElement(publicIps);
         assertFalse(InetAddresses2.isPrivateIPAddress(ip));
         HostAndPort socket = HostAndPort.fromParts(ip, 22);
         assertTrue(socketTester.apply(socket), String.format("failed to open socket %s on node %s", socket, node));

         // check that there is an elastic ip correlating to it
         EC2Api ec2 = context.unwrapApi(EC2Api.class);
         Set<PublicIpInstanceIdPair> ipidpairs =
               ec2.getElasticIPAddressApi().get().describeAddressesInRegion(region, publicIps.toArray(new String[0]));
         assertEquals(ipidpairs.size(), 1, String.format("there should only be one address pair (%s)",
               Iterables.toString(ipidpairs)));

         // check that the elastic ip is in node.publicAddresses
         PublicIpInstanceIdPair ipidpair = Iterables.get(ipidpairs, 0);
         assertEquals(region + "/" + ipidpair.getInstanceId(), node.getId());
        
         // delete the node
         context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));

         // check that the ip is deallocated
         Set<PublicIpInstanceIdPair> ipidcheck =
                 ec2.getElasticIPAddressApi().get().describeAddressesInRegion(region, ipidpair.getPublicIp());
         assertTrue(Iterables.isEmpty(ipidcheck), String.format("there should be no address pairs (%s)",
               Iterables.toString(ipidcheck)));
      } finally {
         context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
         if (context != null)
            context.close();
      }
   }
View Full Code Here

      provider = "glesys";
   }

   @Test
   public void testAndExperiment() {
      ComputeServiceContext context = null;
      try {

         context = ContextBuilder
               .newBuilder(new GleSYSProviderMetadata())
               .overrides(setupProperties())
               .modules(setupModules()).build(ComputeServiceContext.class);

         assertEquals(context.getComputeService().listAssignableLocations().size(), 4);

      } finally {
         Closeables2.closeQuietly(context);
      }
   }
View Full Code Here

TOP

Related Classes of org.jclouds.compute.ComputeServiceContext

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.