Search in sources :

Example 16 with Instance

use of org.apache.whirr.Cluster.Instance in project whirr by apache.

the class VoldemortServiceTest method testInstances.

@Test(timeout = TestConstants.ITEST_TIMEOUT)
public void testInstances() throws Exception {
    Set<Instance> instances = cluster.getInstances();
    String url = "tcp://" + instances.iterator().next().getPublicAddress().getHostAddress() + ":" + ADMIN_PORT;
    AdminClient client = new AdminClient(url, new AdminClientConfig());
    voldemort.cluster.Cluster c = client.getAdminClientCluster();
    List<String> voldemortBasedHosts = new ArrayList<String>();
    for (Node node : c.getNodes()) voldemortBasedHosts.add(node.getHost());
    List<String> whirrBasedHosts = new ArrayList<String>();
    for (Instance instance : instances) whirrBasedHosts.add(instance.getPrivateAddress().getHostAddress());
    Collections.sort(voldemortBasedHosts);
    Collections.sort(whirrBasedHosts);
    Assert.assertEquals(whirrBasedHosts, voldemortBasedHosts);
}
Also used : AdminClientConfig(voldemort.client.protocol.admin.AdminClientConfig) Instance(org.apache.whirr.Cluster.Instance) Node(voldemort.cluster.Node) ArrayList(java.util.ArrayList) AdminClient(voldemort.client.protocol.admin.AdminClient) Test(org.junit.Test)

Example 17 with Instance

use of org.apache.whirr.Cluster.Instance in project whirr by apache.

the class VoldemortServiceTest method waitForBootstrap.

private void waitForBootstrap() {
    for (Instance instance : cluster.getInstances()) {
        while (true) {
            try {
                String url = "tcp://" + instance.getPublicAddress().getHostAddress() + ":" + ADMIN_PORT;
                AdminClient client = new AdminClient(url, new AdminClientConfig());
                client.getAdminClientCluster();
                break;
            } catch (Exception e) {
                System.out.print(".");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e1) {
                    break;
                }
            }
        }
    }
}
Also used : AdminClientConfig(voldemort.client.protocol.admin.AdminClientConfig) Instance(org.apache.whirr.Cluster.Instance) IOException(java.io.IOException) AdminClient(voldemort.client.protocol.admin.AdminClient)

Example 18 with Instance

use of org.apache.whirr.Cluster.Instance in project whirr by apache.

the class YarnNodeManagerHandler method beforeConfigure.

@Override
protected void beforeConfigure(ClusterActionEvent event) throws IOException, InterruptedException {
    ClusterSpec clusterSpec = event.getClusterSpec();
    Configuration conf = getConfiguration(clusterSpec);
    Cluster cluster = event.getCluster();
    Set<Instance> nodeManagers = cluster.getInstancesMatching(role(ROLE));
    if (!nodeManagers.isEmpty()) {
        for (Instance nodeManager : nodeManagers) {
            event.getFirewallManager().addRules(Rule.create().destination(nodeManager).ports(NODE_MANAGER_WEB_UI_PORT));
        }
    }
    handleFirewallRules(event);
    try {
        event.getStatementBuilder().addStatements(build("/tmp/yarn-site.xml", clusterSpec, cluster, ROLE));
    } catch (ConfigurationException e) {
        throw new IOException(e);
    }
    addStatement(event, call(getConfigureFunction(conf)));
    addStatement(event, call(getStartFunction(conf), "nodemanager"));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) Instance(org.apache.whirr.Cluster.Instance) ConfigurationException(org.apache.commons.configuration.ConfigurationException) Cluster(org.apache.whirr.Cluster) ClusterSpec(org.apache.whirr.ClusterSpec) IOException(java.io.IOException)

Example 19 with Instance

use of org.apache.whirr.Cluster.Instance in project whirr by apache.

the class YarnResourceManagerHandler method afterConfigure.

@Override
protected void afterConfigure(ClusterActionEvent event) throws IOException {
    ClusterSpec clusterSpec = event.getClusterSpec();
    Cluster cluster = event.getCluster();
    Instance resourceManager = cluster.getInstanceMatching(role(ROLE));
    LOG.info("Resource manager web UI available at http://{}:{}", resourceManager.getPublicHostName(), RESOURCE_MANAGER_WEB_UI_PORT);
    Properties mrConfig = createClientSideMapReduceProperties(clusterSpec);
    createClientSideMapReduceSiteFile(clusterSpec, mrConfig);
    Properties yarnConfig = createClientSideYarnProperties(clusterSpec, resourceManager);
    createClientSideYarnSiteFile(clusterSpec, yarnConfig);
    Properties combined = new Properties();
    combined.putAll(cluster.getConfiguration());
    combined.putAll(mrConfig);
    combined.putAll(yarnConfig);
    event.setCluster(new Cluster(cluster.getInstances(), combined));
}
Also used : Instance(org.apache.whirr.Cluster.Instance) Cluster(org.apache.whirr.Cluster) ClusterSpec(org.apache.whirr.ClusterSpec) Properties(java.util.Properties)

Example 20 with Instance

use of org.apache.whirr.Cluster.Instance in project whirr by apache.

the class HBaseMasterClusterActionHandler method afterConfigure.

@Override
protected void afterConfigure(ClusterActionEvent event) throws IOException {
    ClusterSpec clusterSpec = event.getClusterSpec();
    Cluster cluster = event.getCluster();
    // TODO: wait for regionservers to come up?
    LOG.info("Completed configuration of {}", clusterSpec.getClusterName());
    Instance instance = cluster.getInstanceMatching(role(ROLE));
    InetAddress masterPublicAddress = instance.getPublicAddress();
    LOG.info("Web UI available at http://{}", masterPublicAddress.getHostName());
    String quorum = ZooKeeperCluster.getHosts(cluster);
    Properties config = createClientSideProperties(masterPublicAddress, quorum);
    createClientSideHadoopSiteFile(clusterSpec, config);
    createProxyScript(clusterSpec, cluster);
    event.setCluster(new Cluster(cluster.getInstances(), config));
}
Also used : Instance(org.apache.whirr.Cluster.Instance) Cluster(org.apache.whirr.Cluster) ZooKeeperCluster(org.apache.whirr.service.zookeeper.ZooKeeperCluster) ClusterSpec(org.apache.whirr.ClusterSpec) Properties(java.util.Properties) InetAddress(java.net.InetAddress)

Aggregations

Instance (org.apache.whirr.Cluster.Instance)36 Cluster (org.apache.whirr.Cluster)19 ClusterSpec (org.apache.whirr.ClusterSpec)14 Configuration (org.apache.commons.configuration.Configuration)10 IOException (java.io.IOException)9 InetAddress (java.net.InetAddress)6 ZooKeeperCluster (org.apache.whirr.service.zookeeper.ZooKeeperCluster)6 Test (org.junit.Test)6 ConfigurationException (org.apache.commons.configuration.ConfigurationException)4 StatementBuilder (org.apache.whirr.service.jclouds.StatementBuilder)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 Properties (java.util.Properties)3 ExecutionException (java.util.concurrent.ExecutionException)3 Future (java.util.concurrent.Future)3 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)3 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)3 InstanceTemplate (org.apache.whirr.InstanceTemplate)3 ClusterActionEvent (org.apache.whirr.service.ClusterActionEvent)3 NodeMetadata (org.jclouds.compute.domain.NodeMetadata)3 Cassandra (org.apache.cassandra.thrift.Cassandra)2