Package org.apache.whirr.service

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


  }

  @Override
  protected void beforeConfigure(ClusterActionEvent event)
      throws IOException, InterruptedException {
    ClusterSpec clusterSpec = event.getClusterSpec();
    Cluster cluster = event.getCluster();
    int port = defaultPort;
    if (configKeyPort != null) {
      port = clusterSpec.getConfiguration().getInt(configKeyPort, defaultPort);
    }

    Cluster.Instance instance = cluster.getInstanceMatching(
      role(HBaseMasterClusterActionHandler.ROLE));
    InetAddress masterPublicAddress = instance.getPublicAddress();

    ComputeServiceContext computeServiceContext =
      ComputeServiceContextBuilder.build(clusterSpec);
    FirewallSettings.authorizeIngress(computeServiceContext, instance,
      clusterSpec, port);

    String hbaseConfigureRunUrl = clusterSpec.getConfiguration().getString(
      HBaseConstants.KEY_CONFIGURE_RUNURL,
      HBaseConstants.SCRIPT_POST_CONFIGURE);
    String master = DnsUtil.resolveAddress(masterPublicAddress.getHostAddress());
    String quorum = ZooKeeperCluster.getHosts(cluster);
      addRunUrl(event, hbaseConfigureRunUrl, role,
        HBaseConstants.PARAM_MASTER, master,
        HBaseConstants.PARAM_QUORUM, quorum,
        HBaseConstants.PARAM_PORT, Integer.toString(port),
        HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
  }
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

  @Override
  protected void doAction(Map<InstanceTemplate, ClusterActionEvent> eventMap)
      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(
View Full Code Here

    addRunUrl(event, "apache/zookeeper/install");
  }

  @Override
  protected void beforeConfigure(ClusterActionEvent event) throws IOException, InterruptedException {
    ClusterSpec clusterSpec = event.getClusterSpec();
    Cluster cluster = event.getCluster();
    LOG.info("Authorizing firewall");
    ComputeServiceContext computeServiceContext =
      ComputeServiceContextBuilder.build(clusterSpec);
    FirewallSettings.authorizeIngress(computeServiceContext,
        cluster.getInstances(), clusterSpec, CLIENT_PORT);
   
    // 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(cluster.getInstancesMatching(
      RolePredicates.role(ZooKeeperClusterActionHandler.ZOOKEEPER_ROLE))));
    addRunUrl(event, "apache/zookeeper/post-configure", "-c",
        clusterSpec.getProvider(),
        servers);
  }
View Full Code Here

        servers);
  }
 
  @Override
  protected void afterConfigure(ClusterActionEvent event) {
    ClusterSpec clusterSpec = event.getClusterSpec();
    Cluster cluster = event.getCluster();
    LOG.info("Completed configuration of {}", clusterSpec.getClusterName());
    String hosts = Joiner.on(',').join(getHosts(cluster.getInstancesMatching(
      RolePredicates.role(ZooKeeperClusterActionHandler.ZOOKEEPER_ROLE))));
    LOG.info("Hosts: {}", hosts);
  }
View Full Code Here

  }

  @Override
  protected void beforeConfigure(ClusterActionEvent event)
      throws IOException, InterruptedException {
    ClusterSpec clusterSpec = event.getClusterSpec();
    Cluster cluster = event.getCluster();
    LOG.info("Authorizing firewall");
    ComputeServiceContext computeServiceContext =
      ComputeServiceContextBuilder.build(clusterSpec);
    FirewallSettings.authorizeIngress(computeServiceContext,
        cluster.getInstances(), clusterSpec, CLIENT_PORT);
    FirewallSettings.authorizeIngress(computeServiceContext,
        cluster.getInstances(), clusterSpec, JMX_PORT);
   
    List<Instance> seeds = getSeeds(cluster.getInstances());
    String servers = Joiner.on(' ').join(getPrivateIps(seeds));
    addRunUrl(event, "apache/cassandra/post-configure",
        "-c", clusterSpec.getProvider(), servers);
  }
View Full Code Here

    if (!optionSet.nonOptionArguments().isEmpty()) {
      printUsage(parser, err);
      return -1;
    }
    try {
      ClusterSpec clusterSpec = getClusterSpec(optionSet);

      Service service = createService(clusterSpec.getServiceName());
      service.destroyCluster(clusterSpec);
      return 0;
    } catch (IllegalArgumentException e) {
      err.println(e.getMessage());
      printUsage(parser, err);
View Full Code Here

      if (config.getString(required.getConfigName()) == null) {
        throw new IllegalArgumentException(String.format("Option '%s' not set.",
            required.getSimpleName()));
      }
    }
    return new ClusterSpec(config);
  }
View Full Code Here

    if (!optionSet.nonOptionArguments().isEmpty()) {
      printUsage(parser, err);
      return -1;
    }
    try {
      ClusterSpec clusterSpec = getClusterSpec(optionSet);

      Service service = createService(clusterSpec.getServiceName());
      Set<? extends NodeMetadata> nodes = service.getNodes(clusterSpec);
      for (NodeMetadata node : nodes) {
        out.println(Joiner.on('\t').join(node.getId(), node.getImageId(),
            getFirstAddress(node.getPublicAddresses()),
            getFirstAddress(node.getPrivateAddresses()),
View Full Code Here

      printUsage(parser, err);
      return -1;
    }
   
    try {
      ClusterSpec clusterSpec = getClusterSpec(optionSet);
      Service service = createService(clusterSpec.getServiceName());
      Cluster cluster = service.launchCluster(clusterSpec);
      out.printf("Started cluster of %s instances\n",
          cluster.getInstances().size());
      out.println(cluster);
      return 0;
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.