Package org.apache.whirr.service.ClusterSpec

Examples of org.apache.whirr.service.ClusterSpec.InstanceTemplate


        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);
View Full Code Here


        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);
View Full Code Here

    TemplateBuilderStrategy strategy = new HadoopTemplateBuilderStrategy();
    strategy.configureTemplateBuilder(clusterSpec, masterTemplateBuilder);
   
    Template masterTemplate = masterTemplateBuilder.build();
   
    InstanceTemplate instanceTemplate = clusterSpec.getInstanceTemplate(MASTER_ROLE);
    checkNotNull(instanceTemplate);
    checkArgument(instanceTemplate.getNumberOfInstances() == 1);
    Set<? extends NodeMetadata> nodes;
    try {
      LOG.info("Starting master node");
      nodes = computeService.runNodesWithTag(
          clusterSpec.getClusterName(), 1, masterTemplate);
      LOG.info("Master node started: {}", nodes);
    } catch (RunNodesException e) {
      // TODO: can we do better here (retry?)
      throw new IOException(e);
    }
    NodeMetadata node = Iterables.getOnlyElement(nodes);
    InetAddress namenodePublicAddress = InetAddress.getByName(Iterables.get(node.getPublicAddresses(),0));
    InetAddress jobtrackerPublicAddress = InetAddress.getByName(Iterables.get(node.getPublicAddresses(),0));
   
    LOG.info("Authorizing firewall");
    FirewallSettings.authorizeIngress(computeServiceContext, node, clusterSpec,
        WEB_PORT);
    FirewallSettings.authorizeIngress(computeServiceContext, node, clusterSpec,
        NAMENODE_WEB_UI_PORT);
    FirewallSettings.authorizeIngress(computeServiceContext, node, clusterSpec,
        JOBTRACKER_WEB_UI_PORT);
    FirewallSettings.authorizeIngress(computeServiceContext, node, clusterSpec,
        namenodePublicAddress.getHostAddress(), NAMENODE_PORT);
    FirewallSettings.authorizeIngress(computeServiceContext, node, clusterSpec,
        namenodePublicAddress.getHostAddress(), JOBTRACKER_PORT);
    if (!namenodePublicAddress.equals(jobtrackerPublicAddress)) {
      FirewallSettings.authorizeIngress(computeServiceContext, node, clusterSpec,
          jobtrackerPublicAddress.getHostAddress(), NAMENODE_PORT);
      FirewallSettings.authorizeIngress(computeServiceContext, node, clusterSpec,
          jobtrackerPublicAddress.getHostAddress(), JOBTRACKER_PORT);
    }

    // Launch slaves (DN and TT)
    Payload slaveBootScript = newStringPayload(runUrls(clusterSpec.getRunUrlBase(),
      String.format("util/configure-hostnames -c %s", clusterSpec.getProvider()),
      "sun/java/install",
      String.format("%s dn,tt -n %s -j %s -c %s",
          hadoopInstallRunUrl,
          namenodePublicAddress.getHostName(),
          jobtrackerPublicAddress.getHostName(),
          clusterSpec.getProvider())));

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

    slaveTemplateBuilder.fromTemplate(masterTemplate); // base on master
    slaveTemplateBuilder.locationId(masterTemplate.getLocation().getId());
   
    Template slaveTemplate = slaveTemplateBuilder.build();
   
    instanceTemplate = clusterSpec.getInstanceTemplate(WORKER_ROLE);
    checkNotNull(instanceTemplate);

    Set<? extends NodeMetadata> workerNodes;
    try {
      LOG.info("Starting {} worker node(s)", instanceTemplate.getNumberOfInstances());
      workerNodes = computeService.runNodesWithTag(clusterSpec.getClusterName(),
        instanceTemplate.getNumberOfInstances(), slaveTemplate);
      LOG.info("Worker nodes started: {}", workerNodes);
    } catch (RunNodesException e) {
      // TODO: don't bail out if only a few have failed to start
      throw new IOException(e);
    }
View Full Code Here

       .osDescriptionMatches("^ubuntu-images.*")
       .architecture(Architecture.X86_32);
   
    Template template = templateBuilder.build();
   
    InstanceTemplate instanceTemplate = clusterSpec.getInstanceTemplate(ZOOKEEPER_ROLE);
    checkNotNull(instanceTemplate);
    int ensembleSize = instanceTemplate.getNumberOfInstances();
    Set<? extends NodeMetadata> nodeMap;
    try {
      nodeMap = computeService.runNodesWithTag(clusterSpec.getClusterName(), ensembleSize,
      template);
    } catch (RunNodesException e) {
View Full Code Here

      templateBuilder.imageNameMatches(".*10\\.?04.*").osDescriptionMatches(
          "^ubuntu-images.*").architecture(Architecture.X86_32);

    Template template = templateBuilder.build();

    InstanceTemplate instanceTemplate = clusterSpec
        .getInstanceTemplate(CASSANDRA_ROLE);
    checkNotNull(instanceTemplate);
    int clusterSize = instanceTemplate.getNumberOfInstances();
    Set<? extends NodeMetadata> nodeMap;
    try {
      nodeMap = computeService.runNodesWithTag(clusterSpec.getClusterName(),
          clusterSize, template);
    } catch (RunNodesException e) {
View Full Code Here

      .osDescriptionMatches("^ubuntu-images.*")
      .architecture(Architecture.X86_32);
   
    Template masterTemplate = masterTemplateBuilder.build();
   
    InstanceTemplate instanceTemplate = clusterSpec.getInstanceTemplate(MASTER_ROLE);
    checkNotNull(instanceTemplate);
    checkArgument(instanceTemplate.getNumberOfInstances() == 1);
    Set<? extends NodeMetadata> nodes;
    try {
      nodes = computeService.runNodesWithTag(
          clusterSpec.getClusterName(), 1, masterTemplate);
    } catch (RunNodesException e) {
      // TODO: can we do better here (retry?)
      throw new IOException(e);
    }
    NodeMetadata node = Iterables.getOnlyElement(nodes);
    InetAddress namenodePublicAddress = InetAddress.getByName(Iterables.get(node.getPublicAddresses(),0));
    InetAddress jobtrackerPublicAddress = InetAddress.getByName(Iterables.get(node.getPublicAddresses(),0));
   
    FirewallSettings.authorizeIngress(computeServiceContext, node, clusterSpec,
        WEB_PORT);
    FirewallSettings.authorizeIngress(computeServiceContext, node, clusterSpec,
        NAMENODE_WEB_UI_PORT);
    FirewallSettings.authorizeIngress(computeServiceContext, node, clusterSpec,
        JOBTRACKER_WEB_UI_PORT);
    FirewallSettings.authorizeIngress(computeServiceContext, node, clusterSpec,
        namenodePublicAddress.getHostAddress(), NAMENODE_PORT);
    FirewallSettings.authorizeIngress(computeServiceContext, node, clusterSpec,
        namenodePublicAddress.getHostAddress(), JOBTRACKER_PORT);
    if (!namenodePublicAddress.equals(jobtrackerPublicAddress)) {
      FirewallSettings.authorizeIngress(computeServiceContext, node, clusterSpec,
          jobtrackerPublicAddress.getHostAddress(), NAMENODE_PORT);
      FirewallSettings.authorizeIngress(computeServiceContext, node, clusterSpec,
          jobtrackerPublicAddress.getHostAddress(), JOBTRACKER_PORT);
    }

    // Launch slaves (DN and TT)
    byte[] slaveBootScript = RunUrlBuilder.runUrls(
      "sun/java/install",
      String.format("%s dn,tt -n %s -j %s",
          hadoopInstallRunUrl,
          namenodePublicAddress.getHostName(),
          jobtrackerPublicAddress.getHostName()));

    TemplateBuilder slaveTemplateBuilder = computeService.templateBuilder()
      .osFamily(UBUNTU)
      .options(runScript(slaveBootScript)
      .installPrivateKey(clusterSpec.readPrivateKey())
      .authorizePublicKey(clusterSpec.readPublicKey()));

    // TODO extract this logic elsewhere
    if (clusterSpec.getProvider().equals("ec2"))
      slaveTemplateBuilder.imageNameMatches(".*10\\.?04.*")
      .osDescriptionMatches("^ubuntu-images.*")
      .architecture(Architecture.X86_32);
   
    Template slaveTemplate = slaveTemplateBuilder.build();
   
    instanceTemplate = clusterSpec.getInstanceTemplate(WORKER_ROLE);
    checkNotNull(instanceTemplate);

    Set<? extends NodeMetadata> workerNodes;
    try {
      workerNodes = computeService.runNodesWithTag(clusterSpec.getClusterName(),
        instanceTemplate.getNumberOfInstances(), slaveTemplate);
    } catch (RunNodesException e) {
      // TODO: don't bail out if only a few have failed to start
      throw new IOException(e);
    }
   
View Full Code Here

    ClusterSpec.withTemporaryKeys(conf);
  }

  @Test(expected = IllegalArgumentException.class)
  public void testRoleMayNotContainSpaces() {
    new InstanceTemplate(1, "a b");
  }
View Full Code Here

   
    Map<InstanceTemplate, Future<Set<? extends NodeMetadata>>> futures =
      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,
          statementBuilder, entry.getValue().getTemplateBuilderStrategy());
     
      Future<Set<? extends NodeMetadata>> nodesFuture = executorService.submit(
        new Callable<Set<? extends NodeMetadata>>() {
          public Set<? extends NodeMetadata> call() throws Exception {
            int num = instanceTemplate.getNumberOfInstances();
            LOG.info("Starting {} node(s) with roles {}", num,
                instanceTemplate.getRoles());
            Set<? extends NodeMetadata> nodes = computeService
                .runNodesWithTag(clusterSpec.getClusterName(), num, template);
            LOG.info("Nodes started: {}", nodes);
            return nodes;
          }
View Full Code Here

    ExecutorService executorService = Executors.newCachedThreadPool();   
    Map<InstanceTemplate, Future<Set<? extends NodeMetadata>>> futures = Maps.newHashMap();
   
    // 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 =
        ComputeServiceContextBuilder.build(getComputeServiceContextFactory(), clusterSpec);
      final ComputeService computeService =
        computeServiceContext.getComputeService();
      final Template template = buildTemplate(clusterSpec, computeService,
          statementBuilder, entry.getValue().getTemplateBuilderStrategy());
     
      Future<Set<? extends NodeMetadata>> nodesFuture = executorService.submit(
          new StartupProcess(
              clusterSpec.getClusterName(),
              instanceTemplate.getNumberOfInstances(),
              instanceTemplate.getMinNumberOfInstances(),
              maxNumberOfRetries,
              instanceTemplate.getRoles(),
              computeService, template, executorService, nodeStarterFactory));
      futures.put(instanceTemplate, nodesFuture);
    }
   
    Set<Instance> instances = Sets.newLinkedHashSet();
View Full Code Here

    ClusterSpec.withTemporaryKeys(conf);
  }

  @Test(expected = IllegalArgumentException.class)
  public void testRoleMayNotContainSpaces() {
    new InstanceTemplate(1, "a b");
  }
View Full Code Here

TOP

Related Classes of org.apache.whirr.service.ClusterSpec.InstanceTemplate

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.