Package org.apache.whirr.service.jclouds

Examples of org.apache.whirr.service.jclouds.StatementBuilder


      Maps.newHashMap();
   
    for (Entry<InstanceTemplate, ClusterActionEvent> entry : eventMap.entrySet()) {
      final InstanceTemplate instanceTemplate = entry.getKey();
      final ClusterSpec clusterSpec = entry.getValue().getClusterSpec();
      StatementBuilder statementBuilder = entry.getValue().getStatementBuilder();
      ComputeServiceContext computeServiceContext =
        ComputeServiceContextBuilder.build(clusterSpec);
      final ComputeService computeService =
        computeServiceContext.getComputeService();
      final Template template = buildTemplate(clusterSpec, computeService,
View Full Code Here


      throws IOException {
   
    for (Entry<InstanceTemplate, ClusterActionEvent> entry : eventMap.entrySet()) {
      ClusterSpec clusterSpec = entry.getValue().getClusterSpec();
      Cluster cluster = entry.getValue().getCluster();
      StatementBuilder statementBuilder = entry.getValue().getStatementBuilder();
      ComputeServiceContext computeServiceContext =
        ComputeServiceContextBuilder.build(clusterSpec);
      ComputeService computeService = computeServiceContext.getComputeService();
      Credentials credentials = new Credentials(
          Iterables.get(cluster.getInstances(), 0).getLoginCredentials().identity,
          clusterSpec.readPrivateKey());
      try {
        LOG.info("Running configuration script");
        Payload script = newStringPayload(statementBuilder.render(OsFamily.UNIX));
        LOG.debug("Running script:\n{}", script.getRawContent());
        computeService.runScriptOnNodesMatching(
            toNodeMetadataPredicate(clusterSpec, cluster, entry.getKey().getRoles()),
            script,
            RunScriptOptions.Builder.overrideCredentialsWith(credentials));
View Full Code Here

      throws IOException {
   
    for (Entry<InstanceTemplate, ClusterActionEvent> entry : eventMap.entrySet()) {
      ClusterSpec clusterSpec = entry.getValue().getClusterSpec();
      Cluster cluster = entry.getValue().getCluster();
      StatementBuilder statementBuilder = entry.getValue().getStatementBuilder();
      ComputeServiceContext computeServiceContext = getCompute().apply(clusterSpec);
      ComputeService computeService = computeServiceContext.getComputeService();
      Credentials credentials = new Credentials(
          clusterSpec.getClusterUser(),
          clusterSpec.getPrivateKey());
      try {
        LOG.info("Running configuration script");
        if (LOG.isDebugEnabled())
          LOG.debug("Running script:\n{}", statementBuilder.render(OsFamily.UNIX));
        computeService.runScriptOnNodesMatching(
            toNodeMetadataPredicate(clusterSpec, cluster, entry.getKey().getRoles()),
            statementBuilder,
            RunScriptOptions.Builder.overrideCredentialsWith(credentials));
        LOG.info("Configuration script run completed");
View Full Code Here

    int numberAllocated = 0;
    Set<Instance> instances = Sets.newLinkedHashSet();
    for (Entry<InstanceTemplate, ClusterActionEvent> entry : eventMap.entrySet()) {

      ClusterSpec clusterSpec = entry.getValue().getClusterSpec();
      final StatementBuilder statementBuilder = entry.getValue().getStatementBuilder();
      ComputeServiceContext computeServiceContext = getCompute().apply(clusterSpec);
      final ComputeService computeService = computeServiceContext.getComputeService();
      Credentials credentials = new Credentials(clusterSpec.getIdentity(), clusterSpec.getCredential());
     
      if (numberAllocated == 0) {
        for (ComputeMetadata compute : computeService.listNodes()) {
          if (!(compute instanceof NodeMetadata)) {
            throw new IllegalArgumentException("Not an instance of NodeMetadata: " + compute);
          }
          nodes.add((NodeMetadata) compute);
        }
      }
      int num = entry.getKey().getNumberOfInstances();
      final List<NodeMetadata> templateNodes =
        nodes.subList(numberAllocated, numberAllocated + num);
      numberAllocated += num;
     
      instances.addAll(getInstances(credentials,
          entry.getKey().getRoles(), templateNodes));
     
      futures.add(executorService.submit(new Callable<Void>() {
        @Override
        public Void call() throws Exception {
          LOG.info("Running script");
          if (LOG.isDebugEnabled())
            LOG.debug("Running script:\n{}", statementBuilder.render(OsFamily.UNIX));
          computeService.runScriptOnNodesMatching(
              Predicates.in(templateNodes),
              statementBuilder);
          LOG.info("Script run completed");
          return null;
View Full Code Here

    // initialize startup processes per InstanceTemplates
    for (Entry<InstanceTemplate, ClusterActionEvent> entry : eventMap.entrySet()) {
      final InstanceTemplate instanceTemplate = entry.getKey();
      final ClusterSpec clusterSpec = entry.getValue().getClusterSpec();
      final int maxNumberOfRetries = clusterSpec.getMaxStartupRetries();
      StatementBuilder statementBuilder = entry.getValue().getStatementBuilder();
      ComputeServiceContext computeServiceContext = getCompute().apply(clusterSpec);
      final ComputeService computeService =
        computeServiceContext.getComputeService();
      final Template template = buildTemplate(clusterSpec, computeService,
          statementBuilder, entry.getValue().getTemplateBuilderStrategy());
View Full Code Here

   
    for (Entry<InstanceTemplate, ClusterActionEvent> entry : eventMap.entrySet()) {
      ClusterSpec clusterSpec = entry.getValue().getClusterSpec();
      Cluster cluster = entry.getValue().getCluster();

      StatementBuilder statementBuilder = entry.getValue().getStatementBuilder();

      ComputeServiceContext computeServiceContext = getCompute().apply(clusterSpec);
      ComputeService computeService = computeServiceContext.getComputeService();

      Credentials credentials = new Credentials(
          clusterSpec.getClusterUser(),
          clusterSpec.getPrivateKey());

      try {
        Map<String, ? extends NodeMetadata> nodesInCluster = getNodesForInstanceIdsInCluster(cluster, computeService);
       
        if (LOG.isDebugEnabled()) {
          LOG.debug("Nodes in cluster: {}", nodesInCluster.values());
        }
       
        Map<String, ? extends NodeMetadata> nodesToApply = Maps.uniqueIndex(
            Iterables.filter(nodesInCluster.values(),
                toNodeMetadataPredicate(clusterSpec, cluster, entry.getKey().getRoles())),
            getNodeId
        );

        LOG.info("Running configuration script on nodes: {}", nodesToApply.keySet());
        if (LOG.isDebugEnabled())
          LOG.debug("script:\n{}", statementBuilder.render(OsFamily.UNIX));
       
        computeService.runScriptOnNodesMatching(
            withIds(nodesToApply.keySet()),
            statementBuilder,
            RunScriptOptions.Builder.overrideCredentialsWith(credentials)
View Full Code Here

  public Cluster execute(ClusterSpec clusterSpec, Cluster cluster) throws IOException, InterruptedException {
   
    Map<InstanceTemplate, ClusterActionEvent> eventMap = Maps.newHashMap();
    Cluster newCluster = cluster;
    for (InstanceTemplate instanceTemplate : clusterSpec.getInstanceTemplates()) {
      StatementBuilder statementBuilder = new StatementBuilder();

      ComputeServiceContext computServiceContext = getCompute().apply(clusterSpec);
      FirewallManager firewallManager = new FirewallManager(computServiceContext,
          clusterSpec, newCluster);
View Full Code Here

    int numberAllocated = 0;
    Set<Instance> instances = Sets.newLinkedHashSet();
    for (Entry<InstanceTemplate, ClusterActionEvent> entry : eventMap.entrySet()) {

      ClusterSpec clusterSpec = entry.getValue().getClusterSpec();
      final StatementBuilder statementBuilder = entry.getValue().getStatementBuilder();
      ComputeServiceContext computeServiceContext = getCompute().apply(clusterSpec);
      final ComputeService computeService = computeServiceContext.getComputeService();
      Credentials credentials = new Credentials(clusterSpec.getIdentity(), clusterSpec.getCredential());
     
      if (numberAllocated == 0) {
        for (ComputeMetadata compute : computeService.listNodes()) {
          if (!(compute instanceof NodeMetadata)) {
            throw new IllegalArgumentException("Not an instance of NodeMetadata: " + compute);
          }
          nodes.add((NodeMetadata) compute);
        }
      }
      int num = entry.getKey().getNumberOfInstances();
      final List<NodeMetadata> templateNodes =
        nodes.subList(numberAllocated, numberAllocated + num);
      numberAllocated += num;
     
      instances.addAll(getInstances(credentials,
          entry.getKey().getRoles(), templateNodes));
     
      futures.add(executorService.submit(new Callable<Void>() {
        @Override
        public Void call() throws Exception {
          LOG.info("Running script");
          if (LOG.isDebugEnabled())
            LOG.debug("Running script:\n{}", statementBuilder.render(OsFamily.UNIX));
          computeService.runScriptOnNodesMatching(
              Predicates.in(templateNodes),
              statementBuilder);
          LOG.info("Script run completed");
          return null;
View Full Code Here

    // initialize startup processes per InstanceTemplates
    for (Entry<InstanceTemplate, ClusterActionEvent> entry : eventMap.entrySet()) {
      final InstanceTemplate instanceTemplate = entry.getKey();
      final ClusterSpec clusterSpec = entry.getValue().getClusterSpec();
      final int maxNumberOfRetries = clusterSpec.getMaxStartupRetries();
      StatementBuilder statementBuilder = entry.getValue().getStatementBuilder();
      ComputeServiceContext computeServiceContext = getCompute().apply(clusterSpec);
      final ComputeService computeService =
        computeServiceContext.getComputeService();
      final Template template = buildTemplate(clusterSpec, computeService,
          statementBuilder, entry.getValue().getTemplateBuilderStrategy());
View Full Code Here

      throws IOException, InterruptedException {

    Map<InstanceTemplate, ClusterActionEvent> eventMap = Maps.newHashMap();
    Cluster newCluster = cluster;
    for (InstanceTemplate instanceTemplate : clusterSpec.getInstanceTemplates()) {
      StatementBuilder statementBuilder = new StatementBuilder();

      ComputeServiceContext computeServiceContext = getCompute().apply(
          clusterSpec);
      FirewallManager firewallManager = new FirewallManager(
          computeServiceContext, clusterSpec, newCluster);
View Full Code Here

TOP

Related Classes of org.apache.whirr.service.jclouds.StatementBuilder

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.